﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>动态添加按钮</title>
</head>
<body>
    <p id="demo">单击按钮创建有文字信息的按钮</p>
    <button onclick="myFunction()">添加按钮</button>
    <script>
        function myFunction() {
            let btn = document.createElement("BUTTON");
            let t = document.createTextNode("动态添加的按钮");
            btn.appendChild(t);
            document.body.appendChild(btn);
        };
    </script>
</body>
</html>